<template>
  <div class="app-container">
    <el-steps
      :active="3"
      process-status="wait"
      align-center
      style="margin-bottom: 40px"
    >
      <el-step title="步骤1" description="编辑基本信息"></el-step>
      <el-step title="步骤2" description="上传详细信息"></el-step>
      <el-step title="步骤3" description="信息审核确认"></el-step>
    </el-steps>

    <el-descriptions
      title="教师信息表格"
      direction="vertical"
      :column="4"
      border
    >
      <el-descriptions-item label="教工号">{{
        teacher.teacherId
      }}</el-descriptions-item>
      <el-descriptions-item label="所在学院">{{
        teacher.collegeName
      }}</el-descriptions-item>
      <el-descriptions-item label="姓名">{{
        teacher.teacherName
      }}</el-descriptions-item>
      <el-descriptions-item label="昵称">{{
        teacher.nickName
      }}</el-descriptions-item>
      <el-descriptions-item label="性别">
        <el-tag size="small">{{ teacher.sex }}</el-tag>
      </el-descriptions-item>
      <el-descriptions-item label="职称">
        <el-tag size="small">{{ teacher.rank }}</el-tag>
      </el-descriptions-item>
      <el-descriptions-item label="电话号码">{{
        teacher.tel
      }}</el-descriptions-item>
      <el-descriptions-item label="邮箱">{{
        teacher.email
      }}</el-descriptions-item>
      <el-descriptions-item label="民族">{{
        teacher.nationality
      }}</el-descriptions-item>

      <el-descriptions-item label="密码">{{
        teacher.password
      }}</el-descriptions-item>
    </el-descriptions>

    <div class="btn">
      <el-button type="primary" @click="saveTeacher()">立即创建</el-button>
      <el-button @click="previous()">返回修改</el-button>
    </div>
  </div>
</template>

<script>
import teacherApi from "@/api/teacher";
export default {
  data() {
    return {
      rankList: [],
      CollegeList: [],
      teacher: {},
    };
  },
  methods: {
    getTeacherInfoById() {
      console.log(this.teacher.teacherId);
      teacherApi.getTeacherById(this.teacher.teacherId).then((res) => {
        this.teacher = res.data.teacher;
      });
    },
    previous() {
      this.$router.push({ path: "/teacher/detail/" + this.teacher.teacherId });
    },
    saveTeacher() {
      this.$message({
        type: "success",
        message: "添加教师信息成功!",
      });
      this.$router.push({ path: "/teacher/list" });
    },
  },

  created() {
    if (this.$route.params && this.$route.params.id) {
      this.teacher.teacherId = this.$route.params.id;
      console.log(this.$route.params.id);
    }


    this.getTeacherInfoById();
  },
};
</script>

<style>
.btn {
  margin: 10px 10px;
  text-align: center;
}
</style>